package com.leilbase.oauthtest.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

/**
 * @program: sc-alibaba
 * @description: 资源服务配置
 * @author: Leil
 * @create: 2019-08-22 17:15
 */
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {

    @Override
    public void configure(HttpSecurity http) throws Exception {
//        http.authorizeRequests().anyRequest().authenticated();
        http
                .authorizeRequests()
                .antMatchers("/hello/testDel")
                .hasAuthority("ADMIN")
                .anyRequest()
                .authenticated();
    }
}
